/*
package cloud.xlh.my_system.login.custom.service.impl;

import cloud.xlh.my_system.common.Result;
import cloud.xlh.my_system.mapper.login.custom.UserMapper;
import cloud.xlh.my_system.pojo.User;
import cloud.xlh.my_system.login.custom.service.CustomLoginService;
import cloud.xlh.my_system.utils.password_security.DecodedRandomStringAndPasswordHelper;
import cloud.xlh.my_system.utils.password_security.EncodedRandomStringHelper;
import cloud.xlh.my_system.utils.password_security.RSAUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

*/
/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : xlh_osms
 * @ Author: XuLeHuang
 * @ Date: 2022/6/26 17:29
 * @ Description:
 *//*

@Service
@Transactional
public class CustomLoginServiceImpl implements CustomLoginService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public Result doLogin(HashMap hashMap) {
        String name = (String) hashMap.get("name");
        String password = (String) hashMap.get("password");
        Subject subject = SecurityUtils.getSubject();
        UsernamePasswordToken usernamePasswordToken =
                new UsernamePasswordToken(name, password);
        subject.login(usernamePasswordToken);
        //用户名+密码查找用户
        User isExist = userMapper.findByNameAndPassword(name , password);
        if (isExist == null) {
            return new Result("登陆失败，请检查账号密码！");
        }
        return new Result("0" , "登陆成功！");
    }

    @Override
    public Result getEncodedRandomString() {
        try {
            String randomStringEncodeByDecodeRsaPublicKeyWithBase64 = EncodedRandomStringHelper.getEncodedRandomStringByRsa();
            Map rsaMap = EncodedRandomStringHelper.getRsaMap();
            String rsaPrivateKey =  (String) RSAUtil.getPrivateKey(rsaMap);
            System.out.println("base64编码的私钥：" +  rsaPrivateKey);
            HashMap<String, String> dataMap = new HashMap<>();
            dataMap.put("randomStringEncodeByDecodeRsaPublicKeyWithBase64" , randomStringEncodeByDecodeRsaPublicKeyWithBase64);
            dataMap.put("rsaPrivateKey" , rsaPrivateKey);
            return new Result("0" , "Rsa加密随机字符串获取成功" , dataMap);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public Result doRegister(User user) throws UnsupportedEncodingException {
        String password = DecodedRandomStringAndPasswordHelper.getPasswordByEncodedString(user.getPassword());
        System.out.println(password);
        //密码MD5加密
        //数据库插入逻辑。。。。
        return null;
    }

}
*/
